Return to the table of contents


Where Am I, Anyway?

Now that you've reached the end of this book, there are some questions that have probably occurred to you. For example,

  1. Am I a programmer now?
  2. What am I qualified to do?
  3. Where do I go from here?
  4. Is that all there is to C++?

The answers to the first three of these questions, as usual with such open-ended topics, is "It all depends". Of course, I can give you some general answers; let's start with questions 1 and 2.

Yes, in the broadest sense, you are a programmer. You've read a fair amount of code and written some programs yourself. But, of course, this doesn't mean that you're a professional programmer. As I said way back at the beginning, no book can turn a novice into a professional programmer. Being a professional in any field takes a lot of hard work, and although you've undoubtedly worked hard in understanding this book, you've just begun the exploration of programming.

Questions 3 and 4 are also closely related. You now have enough background that you should be able to get some benefit from a well-written book about C++ that assumes you are already acquainted with programming; that would be a good way to continue. As for whether we've covered everything about C++, the answer is unequivocal: absolutely not. I would estimate that we have examined perhaps 5% of the very large, complicated, and powerful C++ language; however, that 5% is the foundation for the rest of your learning in this subject. Most books try to cover every aspect of the language and, as a result, cannot provide the deep coverage of fundamentals; I've worked very hard to ensure that you have the correct tools to continue your learning.

A Few Odds and Ends

I've skipped over some topics because they weren't essential to the discussion. However, since they are likely to be covered in any other book that you might read on programming in C++, I'll discuss them here briefly. This will ensure that they won't be completely foreign to you when you encounter them in your future reading.

Operator Precedence

You may recall from high school arithmetic that an expression like 5 + 3 * 9, is calculated as though it were written 5 + (3 * 9), not (5 + 3) * 9; that is, you have to do the * before the +, so that the correct result is 32, not 72, as it would be under the latter interpretation. The reason for performing the operations in the former order is that multiplication has a higher precedence than addition. Well, every operator in C++ also has a precedence that determines the order of application of each operator in an expression with more than one operator. This seems like a good idea at first glance, since after all, arithmetic does follow precedence rules like the one we just saw. Unfortunately, C++ is just a little more complicated than arithmetic, and so its precedence rules are not as simple and easy to remember as those of arithmetic. In fact, there are 17 different levels of precedence, which no one can remember. Therefore, everyone (or at least, everyone who is sensible) ends up using parentheses to specify what order was meant when the expression was written; of course, if we're going to have to use parentheses, then why do we need the precedence rules in the first place?

Other Native Data Types

We've confined our use of native data types to short, unsigned short, char, int (for the return type of main only), and bool. As I mentioned in Chapter inventor.htm, there are other native types; you'll be seeing them in other programs and in other textbooks, so I should tell you about them now. By the way, I haven't avoided them because they're particularly difficult to use; the reason is simply that they weren't necessary to the task at hand, which was teaching you how to program, using C++. Now that we have accomplished that task, you might as well add them to your arsenal of tools. These other native types are

  1. float
  2. double
  3. long (signed or unsigned)

The float and double types are used to store values that can contain fractional parts, (so-called floating-point numbers), rather than being restricted to whole numbers as in the case of short and the other integral types. Of course, this raises two questions: First, why don't we use these types all the time, if they're more flexible? Second, why are there two of these types rather than only one? These questions are related, because the main difference between float and double is that a float is 4 bytes long and a double is 8 bytes long; therefore, a double can store larger values and maintain higher accuracy. However, it also uses up twice the amount of memory of a float, which may not be important when we're dealing with a few values but is quite important if we have a vector or array of thousands or tens of thousands of elements.

So that explains why we'd use a float rather than a double, but not why we would use a long rather than a float; after all, they both take up four bytes. The reason that we would use a long is that it can store larger whole values than a float while retaining exact accuracy in results. Also, on a machine that doesn't have a built-in numeric processor, longs can be processed much more rapidly than than floats.

protected Species

The protected keyword is another access specifier, like public and private. The reason that we haven't covered it in this book is that it is not used except in situations where we create a class that is "descended" from another class. This topic is sufficiently complex as to be the subject of several chapters in the sequel to this book, Who's Afraid of More C++?, and is therefore not covered in this book due to space limitations.


Return to the table of contents